/*    */ package com.qmsk.business.megSend;
/*    */ 
/*    */ import java.io.UnsupportedEncodingException;
/*    */ import java.net.URL;
/*    */ import java.util.Map;
/*    */ import java.util.concurrent.ExecutorService;
/*    */ import java.util.concurrent.Executors;
/*    */ import java.util.concurrent.Future;
/*    */ import org.slf4j.Logger;
/*    */ import org.slf4j.LoggerFactory;
/*    */ 
/*    */ public class MsgSendManage
/*    */ {
/* 14 */   private static final Logger log = LoggerFactory.getLogger(MsgSendManage.class);
/*    */   private static ExecutorService service;
/*    */   public static Map<String, String> account;
/*    */ 
/*    */   static
/*    */   {
/* 19 */     getInstance();
/*    */   }
/*    */ 
/*    */   public static boolean sendSMS(String mp, String msg) {
/*    */     try {
/* 24 */       SMSRunner sms = new SMSRunner(getSMSInfo(mp, msg));
/* 25 */       Future futrue = service.submit(sms);
/* 26 */       return ((Boolean)futrue.get()).booleanValue();
/*    */     } catch (Exception e) {
/* 28 */       log.error(e.getMessage());
/*    */     }
/* 30 */     return false;
/*    */   }
/*    */ 
/*    */   public static boolean sendEmail(String email, String subject, String content) {
/*    */     try {
/* 35 */       MailRunner sms = new MailRunner(
/* 36 */         getMailInfo(email, subject, content));
/* 37 */       Future futrue = service.submit(sms);
/* 38 */       return ((Boolean)futrue.get()).booleanValue();
/*    */     } catch (Exception e) {
/* 40 */       log.error(e.getMessage());
/*    */     }
/* 42 */     return false;
/*    */   }
/*    */ 
/*    */   private static synchronized void getInstance() {
/* 46 */     if (service == null) {
/* 47 */       service = Executors.newCachedThreadPool();
/*    */     }
/* 49 */     if (account == null)
/* 50 */       account = PropertiesUtil.readProperties(MsgSendManage.class
/* 51 */         .getClassLoader().getResource("").getPath() + 
/* 52 */         "sendAccount.properties");
/*    */   }
/*    */ 
/*    */   private static MailInfo getMailInfo(String email, String subject, String content)
/*    */     throws UnsupportedEncodingException
/*    */   {
/* 58 */     MailInfo mailInfo = new MailInfo();
/* 59 */     mailInfo.setFromAddress((String)account.get("mail_fromAddr"));
/* 60 */     mailInfo.setValidate((String)account.get("mail_validate"));
/* 61 */     mailInfo.setMailServerHost((String)account.get("mail_host"));
/* 62 */     mailInfo.setMailServerPort((String)account.get("mail_port"));
/* 63 */     mailInfo.setUsername((String)account.get("mail_userName"));
/* 64 */     mailInfo.setPassword((String)account.get("mail_pwd"));
/* 65 */     mailInfo.setProtocol((String)account.get("mail_protocol"));
/* 66 */     mailInfo.setToAddress(email);
/* 67 */     mailInfo.setSubject(subject);
/* 68 */     mailInfo.setContent(content);
/* 69 */     return mailInfo;
/*    */   }
/*    */ 
/*    */   private static SMSInfo getSMSInfo(String mp, String msg) throws UnsupportedEncodingException
/*    */   {
/* 74 */     SMSInfo smsInfo = new SMSInfo();
/* 75 */     smsInfo.setServerUrl((String)account.get("sms_serverUrl"));
/* 76 */     smsInfo.setSname((String)account.get("sms_account"));
/* 77 */     smsInfo.setSpwd((String)account.get("sms_pwd"));
/* 78 */     smsInfo.setSprdid((String)account.get("sms_sprdId"));
/* 79 */     smsInfo.setScorpid((String)account.get("sms_scorpId"));
/* 80 */     smsInfo.setSendMp(mp);
/* 81 */     smsInfo.setSmsg(msg);
/* 82 */     return smsInfo;
/*    */   }
/*    */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.megSend.MsgSendManage
 * JD-Core Version:    0.5.3
 */